#include "trdp.hpp"
#include <memory>
#include <thread>
int main(int argc, char **argv)
{
	if (argc < 3)
	{
		printf("usage: %s [local ip] [multi ip]\n", argv[0]);
		return 0;
	}

	try
	{
		trdp::init(std::string(argv[1]), std::string(argv[2]));
		printf("initialized trdpmini %s %s\n", argv[1], argv[2]);
		auto sub = std::make_shared<trdp::pd_sub>(0x1234, 16);
		printf("created subscriber\n");
		char data[17];
		data[16] = '\0';
		while (true)
		{
			if (sub->update((uint8_t *)data, 16) > 0)
			{
				printf("recv: %s\n", data);
			}
			std::this_thread::sleep_for(std::chrono::milliseconds(10));
		}
	}
	catch (TRDP_MINI_ERR_T err)
	{
		printf("exception: %d\n", err);
	}

	return 0;
}
